/*******************************************************************************
*  Project      : Minigate Golfin                                 
*  Program ID   : common.js                                 
*  Description  : 기본함수                                             
*
********************************************************************************
*  Program History                                                            
*  Date        Author    Description                                          
*  ----------  --------  -------------------------------------------------------- 
*  2012-04-03  김효순    Created.                                             
*  2012-04-09  김효순    getParam 추가     
*  2012-04-10  김효순    로그인, 로그아웃 처리
*  2012-04-12  김효순    left 메뉴 펼침기능
*  2012-04-18  김효순    모달로딩 클래스 추가
*  2012-04-18  김효순    아이디, 비밀번호 찾기 링크 추가
*******************************************************************************/
var _ROOT = "/sky72web";

function fnLoadingJS(url, callback)
{
	var head= document.getElementsByTagName('head')[0];
	var script= document.createElement('script');
	script.type= 'text/javascript';
	var loaded = false;
	script.onreadystatechange= function () {
		
		if (this.readyState == 'loaded' || this.readyState == 'complete') {
			if (loaded) {
				return;
			}
			loaded = true;
			callback();
		}
	}


	script.onload = function () {
		callback();
	}

	script.src = url;
	head.appendChild(script);
}

if(!String.trim){
	String.prototype.trim = function(){
		return this.replace(/^\s*/, "").replace(/\s*$/, "");
	}
}

document.write("<style>body{display:none;}</style>");

jQuery(function($){
	$("body").show();
	
	$("form").submit(function(event){
		event.preventDefault();
		
		return false;
	});
	
	$("div#container>*:not(div#left_area)").delegate("a", "click", function(event){
		event.preventDefault();
	});
	
	$("body#pop_wrap").delegate("a", "click", function(event){
		event.preventDefault();
	});
	
	
	
	// 로딩 에니메이션
	$.fn.spin = function(opts) {
		this.each(function() {
			var $this = $(this),
			data = $this.data();
			
			if (data.spinner) {
				data.spinner.stop();
				delete data.spinner;
			}
			if (opts !== false) {
				data.spinner = new Spinner($.extend({color: $this.css('color')}, opts)).spin(this);
			}
		});
		return this;
	};
	
	// 특정 텍스트 감싸기
	$.fn.textWrap = function(pat, DOMText) {
		function innerWrap(node, pat) {
			var skip = 0;
			if (node.nodeType == 3) {
				var pos = node.data.toUpperCase().indexOf(pat);
				if (pos >= 0) {
					var middlebit = node.splitText(pos);
					var endbit = middlebit.splitText(pat.length);
					$(middlebit).wrap(DOMText);
					skip = 1;
				}
			}
			else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {
				for (var i = 0; i < node.childNodes.length; ++i) {
					i += innerWrap(node.childNodes[i], pat);
				}
			}
			return skip;
		}
		
		return this.each(function() {
			innerWrap(this, pat.toUpperCase());
		});
	};
	
	// top 메뉴
	function clsTopMenu()
	{
		this._HTMLDom = null;
		
		this.bookingAlarmList = null;
		this.friendAlarmList = null;
		this.alarmList = null;
		
		this.bLoaded = false;
		this._loadpage = "../inc/top.html";
		this._load();
	}
	
	clsTopMenu.prototype = {
		_load : function(){
			var thisClass = this;
			if($("header").children().length > 0){
				$("header").prepend("<div></div>").children(":first").load(this._loadpage, function(){thisClass._init();});	
			}else{
				$("header").load(this._loadpage, function(){thisClass._init();});
			}
		}
		, _init: function(){
			var $layer = $("div.top_menu");
			
			this._HTMLDom = {
				"$layer": $layer
				, "$btnLogout": $layer.find("#idBtnLogout")
			}
			
			this.bookingAlarmList = [];
			
			this.friendAlarmList = [];
			
			this.alarmList = [];
			
			this._HTMLDom["$btnLogout"].hide();
			
			$layer.find("ul:first>li:eq(0)>a:first").click(function(event){
				event.preventDefault();
				
				$layer.find("ul:first>li:eq(0) div.top_booking").toggle("fast");
				$layer.find("ul:first>li:eq(1) div.top_friend").hide("fast");
				$layer.find("ul:first>li:eq(2) div.top_info").hide("fast");
			}).parent().find("span.boo").html(0);
			
			$layer.find("ul:first>li:eq(1)>a:first").click(function(event){
				event.preventDefault();
				
				$layer.find("ul:first>li:eq(0) div.top_booking").hide("fast");
				$layer.find("ul:first>li:eq(1) div.top_friend").toggle("fast");
				$layer.find("ul:first>li:eq(2) div.top_info").hide("fast");
			}).parent().find("span.frie").html(0);
			
			$layer.find("ul:first>li:eq(2)>a:first").click(function(event){
				event.preventDefault();
				
				$layer.find("ul:first>li:eq(0) div.top_booking").hide("fast");
				$layer.find("ul:first>li:eq(1) div.top_friend").hide("fast");
				$layer.find("ul:first>li:eq(2) div.top_info").toggle("fast");
			}).parent().find("span.info").html(0);
			
			$layer.find("ul:first>li:eq(0) div.top_booking").hide().find("ul").empty();;
			$layer.find("ul:first>li:eq(1) div.top_friend").hide().find("ul").empty();;
			$layer.find("ul:first>li:eq(2) div.top_info").hide().find("ul").empty();;
			
			$(this).trigger("onload");
		}
		, $getBtnLogout: function(){
			return this._HTMLDom["$btnLogout"];
		}
		, getLoaded: function(){
			var bLoaded = false;
			
			if(this._HTMLDom && this._HTMLDom["$layer"].length > 0) bLoaded = true;
			return bLoaded;
		}
		, setBookingAlarmList: function(thisData){
			this.bookingAlarmList = thisData;
			this.display();
		}
		, setFriendAlarmList: function(thisData){
			this.friendAlarmList = thisData;
			this.display();
		}
		, setAlarmList: function(thisData){
			this.alarmList = thisData;
			this.display();
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var member_id = document.objGlobal.getCookie("member_id");
			var $bookingAlarmLayer = $layer.find("ul:first>li:eq(0) div.top_booking");
			var $friendAlarmLayer =  $layer.find("ul:first>li:eq(1) div.top_friend");
			var $alarmLayer =  $layer.find("ul:first>li:eq(2) div.top_info");
			var thisClass = this;
			
			$layer.find("ul:first>li:eq(0) span.boo").html(this.bookingAlarmList.length);
			$layer.find("ul:first>li:eq(1) span.frie").html(this.friendAlarmList.length);
			$layer.find("ul:first>li:eq(2) span.info").html(this.alarmList.length);
			
			// 부킹 알람 리스트
			$bookingAlarmLayer.find("ul").empty();
			for(var i=0;i<this.bookingAlarmList.length;i++){
				var szNick = this.bookingAlarmList[i]["닉네임"];
				var szMessage = this.bookingAlarmList[i]["메시지"];
				//if(!szNick) szNick = "";
				
				switch(this.bookingAlarmList[i]["종류"]){
					case "부킹예약":
						$bookingAlarmLayer.find("ul").append("<li><div>" + this.bookingAlarmList[i]["메시지"] + "</div></li>");
						break;
					case "조인룸초대":
						$bookingAlarmLayer.find("ul").append("<li></li>");
						$bookingAlarmLayer.find("ul>li:last").append("<div>" + this.bookingAlarmList[i]["메시지"] + "</div>\n");
						$bookingAlarmLayer.find("ul>li:last").append("<div class='top_bt'>\n<a href='#'><img src='../images/btn/btn_accept.gif' alt='수락'></a>\n<a href='#'><img src='../images/btn/btn_deny.gif' alt='거부'></a>\n</div>");
						$bookingAlarmLayer.find("ul>li:last a:eq(0)").click({"n": i}, function(event){
							event.preventDefault();
							var n = event.data["n"];
							
							alert(thisClass.bookingAlarmList[n]["아이디"] + "수락");
						});
						$bookingAlarmLayer.find("ul>li:last a:eq(1)").click({"n": i}, function(event){
							event.preventDefault();
							var n = event.data["n"];
							
							alert(thisClass.bookingAlarmList[n]["아이디"] + "거부");
						});
						break;
					case "조인룸참여":
						$bookingAlarmLayer.find("ul").append("<li><div>" + this.bookingAlarmList[i]["메시지"] + "</div></li>");
						break;
					case "예정조인룸참여":
						$bookingAlarmLayer.find("ul").append("<li><div>" + this.bookingAlarmList[i]["메시지"] + "</div></li>");
						break;
					default: 
						$bookingAlarmLayer.find("ul").append("<li><div>" + this.bookingAlarmList[i]["메시지"] + "</div></li>");
						break;
				}
				
				if(szNick) $bookingAlarmLayer.find("ul>li:last").textWrap(szNick, "<span class='top_txt02' />");
				var aDate = szMessage.match(/(\d{4}\.\d{2}\.\d{2})/gi);
				
				if(aDate){
					for(var x=0;x<aDate.length;x++){
						$bookingAlarmLayer.find("ul>li:last").textWrap(aDate[x], "<span class='top_txt01' />");
					}
				}
			}
			
			// 친구 알람 리스트
			$friendAlarmLayer.find("ul").empty();
			for(var i=0;i<this.friendAlarmList.length;i++){
				var szNick = this.friendAlarmList[i]["닉네임"];
				var szMessage = this.friendAlarmList[i]["메시지"];
				
				switch(this.friendAlarmList[i]["종류"]){
					case "친구요청":
						$friendAlarmLayer.find("ul").append("<li><div class='top_fr_cont'></div></li>");
						$friendAlarmLayer.find("ul>li:last>div").append("<p class='top_photo'><img src='" + this.friendAlarmList[i]["이미지"] + "' alt='' width='35' height='35' /></p>");
						$friendAlarmLayer.find("ul>li:last>div").append("<div class='top_accept'><p>" + this.friendAlarmList[i]["메시지"] + "</p></div>");
						$friendAlarmLayer.find("ul>li:last>div>div.top_accept").append("<p>\n<a href='#'><img src='../images/btn/btn_accept.gif' alt='수락'></a>\n<a href='#'><img src='../images/btn/btn_deny.gif' alt='거부'></a>\n</p>");
						
						$friendAlarmLayer.find("ul>li:last a:eq(0)").click({"n": i}, function(event){
							event.preventDefault();
							var n = event.data["n"];
							
							alert(thisClass.friendAlarmList[n]["아이디"] + "수락");
						});
						$friendAlarmLayer.find("ul>li:last a:eq(1)").click({"n": i}, function(event){
							event.preventDefault();
							var n = event.data["n"];
							
							alert(thisClass.friendAlarmList[n]["아이디"] + "거부");
						});
						break;
					default:
						$friendAlarmLayer.find("ul").append("<li><div>" + this.friendAlarmList[i]["메시지"] + "</div></li>");
						break;
				}
				
				if(szNick) $friendAlarmLayer.find("ul>li:last").textWrap(szNick, "<span class='top_txt' />");
			}
			
			// 알람 리스트
			$alarmLayer.find("ul").empty();
			for(var i=0;i<this.alarmList.length;i++){
				var szNick = this.alarmList[i]["닉네임"];
				
				$alarmLayer.find("ul").append("<li><div>" + this.alarmList[i]["메시지"] + "</div></li>");
				
				if(szNick) $alarmLayer.find("ul>li:last").textWrap(szNick, "<span class='top_txt' />");
			}
			
			if(document.objGlobal.getCookie("member_id")) this._HTMLDom["$btnLogout"].show();
		}
	}
	
	
	// left 메뉴
	function clsLeftMenu()
	{
		this._HTMLDom = null;
		
		this._loadpage = "../inc/left_content.html";
		this._menu = null;
		this.actionTimer = null;
		this._load();
	}
	
	
	clsLeftMenu.prototype = {
		_load : function(){
			var thisClass = this;
			this._menu = {
				"1st": null
				, "2nd": null
			};
			
			$("#left_area").load(this._loadpage, function(){thisClass._init();});
		}
		, _init: function(){
			var $layer = $("#left_content");
			
			this._HTMLDom = {
				"$layer": $layer
				, "$btnLogin": $layer.find("p.btn_log")
				, "$loginLayer": $layer.find("dl.left_member")
				, "$loginfoLayer": $layer.find("dl.left_profile")
				, "$loginIDInput": $layer.find(".left_member").find(":text:first")
				, "$loginPasswdInput": $layer.find(".left_member").find("input[type=password]")
				, "$menuBox": $layer.find("nav.gnb_area")
				, "$collectionMenuStep1": $layer.find(".gnb_area").find("li:has(h3)").find("h3")
				, "$collectionMenuStep2": $layer.find(".gnb_area").find("ul:not(.gnb)")
			}
			
			$layer.find("dl.left_member>dd.id_save>p:eq(1)>a").hide();
			$layer.find("dl.left_profile>dd>p.mem_link").click(function(event){
				event.preventDefault();
				
				window.open("../mypage/my_home.html");
			});
			
			document.objGlobal.setPlaceHolder();
			
			// 로그인 창 또는 로그인 정보
			if(document.objGlobal.getCookie("member_id")){
				this._HTMLDom["$loginLayer"].remove();
			}else{
				this._HTMLDom["$loginfoLayer"].remove();
			}
			
			
			var aFileName = document.location.href.match(/(?:.+)\/(.+)\/(.+)\.(html|htm)/);
			if(aFileName[1] == "field"){
				// 필드메뉴 on
				this._menu["1st"] = "0"
				
				switch(aFileName[2]){
					case "field":
					case "field_write":
						this._menu["2nd"] = "0";
						break;
					case "my_field":
						this._menu["2nd"] = "1";
						break;
				}
			}else if(aFileName[1] == "booking"){
				// 부킹메뉴 on
				this._menu["1st"] = "2"
				
				switch(aFileName[2]){
					case "booking":
					case "booking_write":
					case "booking_view":
						this._menu["2nd"] = "0";
						break;
					// 조인룸은 메뉴 재편성됨.
					case "join_room":
					case "join_room_creat":
					case "join_room_view01":
						this._menu["1st"] = "1";
						//this._menu["2nd"] = "0";
						break;
				}
			}else if(aFileName[1] == "club"){
				// 동호회메뉴 on
				this._menu["1st"] = "3"
				
				switch(aFileName[2]){
					case "club":
						this._menu["2nd"] = "0";
						break;
					case "club_my":
						this._menu["2nd"] = "1";
						break;
				}
			}else if(aFileName[1] == "course"){
				// 코스메뉴 on
				this._menu["1st"] = "4"
			}
			
			// 하위메뉴 숨김
			this._HTMLDom["$menuBox"].find("ul:not(.gnb)").hide();
			
			
			// 대메뉴 마우스 오버위한 데이터링
			this._HTMLDom["$menuBox"].find("li:has(h3)").find("h3").find("img").each(function(){
				$(this).data("src", this.src.replace(".gif", ""));
			});
			
			// 하위메뉴 마우스 오버위한 데이터링
			this._HTMLDom["$menuBox"].find("li:has(h3):has(ul)").find("ul").find("img").each(function(){
				$(this).data("src", this.src.replace(".gif", ""));
			});
			
			$(this).trigger("onload");
		}
		, $getBtnLogin: function(){
			return this._HTMLDom["$btnLogin"];
		}
		, $getInputID: function(){
			return this._HTMLDom["$loginIDInput"];
		}
		, $getInputPasswd: function(){
			return this._HTMLDom["$loginPasswdInput"];
		}
		, $getsMenuStep1: function(){
			return this._HTMLDom["$collectionMenuStep1"];
		}
		, $getsMenuStep2: function(){
			return this._HTMLDom["$collectionMenuStep2"];
		}
		, $getBtnFindIdPw: function(){
			var $layer = this._HTMLDom["$layer"];
			
			return $layer.find("dl.left_member dt a:eq(1)");
		}
		, getMenu: function(key){
			return this._menu[key];
		}
		, setDefault: function(){
			if(!this.actionTimer) return;
			
			// 디폴트 메뉴 설정
			if(this.getMenu("1st")){
				(this.$getsMenuStep1()).parent("li").eq(this.getMenu("1st")).find("h3").trigger("mouseenter");
				
				if(this.getMenu("2nd")){
					(this.$getsMenuStep1()).parent("li").eq(this.getMenu("1st")).find("ul").find("li").eq(this.getMenu("2nd")).trigger("mouseenter");
				}
			}
		}
		, getLoaded: function(){
			var bLoaded = false;
			
			if(this._HTMLDom && this._HTMLDom["$layer"].length > 0) bLoaded = true;
			return bLoaded;
		}
		, setActionTimer: function(val){
			this.actionTimer = val;
		}
		, getActionTimer: function(){
			return this.actionTimer;
		}
		, loginSpinStart: function(){
			var $loginLayer = this._HTMLDom["$loginLayer"];
			
			$loginLayer.hide();
			if($loginLayer.parent().find("div#tmpSpin").length == 0){
				$loginLayer.parent().prepend("<div id='tmpSpin' style='position:relative; width:225px; height:100px;'></div>");
			}
			$loginLayer.prev("div#tmpSpin").spin().show();
		}
		, loginSpinEnd: function(){
			var $loginLayer = this._HTMLDom["$loginLayer"];
			
			$loginLayer.prev("div#tmpSpin").spin(false).hide();
			$loginLayer.show();
		}
	}
	
	// mypage top
	function clsMypageTop()
	{
		this._HTMLDom = null;
		this.memberInfo = null;
		
		this.bLoaded = false;
		this._loadpage = "../inc/mypage_top.html";
		this._load();
	}
	
	clsMypageTop.prototype = {
		_load : function(){
			var thisClass = this;
			if($("header>div#top_cont>div.top_mypage").length > 0) $("header>div#top_cont>div.top_mypage").load(this._loadpage, function(){thisClass._init();});
		}
		, _init: function(){
			var $layer = $("header>div#top_cont>div.top_mypage");
			
			this._HTMLDom = {
				"$layer": $layer
			}
			
			this.memberInfo = {
				"이미지": null
				, "닉네임": null
				, "점수": null
				, "성별": null
				, "핸디": null
				, "비거리": null
			}
			
			this.display();
		}
		, setMemberInfo: function(thisData){
			this.memberInfo = thisData;
			this.display();
		}
		, getInfoData: function(){
			return this.memberInfo;
		}
		, display: function(){
			if(!this._HTMLDom) return;
			var $layer = this._HTMLDom["$layer"];
			
			var aFileName = document.location.href.match(/(?:.+)\/(.+)\/(.+)\.(html|htm)/);
			var idx = null;
			
			$layer.find("nav li").removeClass("gnb_on").find("img").each(function(){
				var imgName = $(this).attr("src").replace("_on.png", ".png");
				$(this).attr("src", imgName);
			});
			
			switch(aFileName[2]){
				case "my_home":
					idx = 0;
					break;
				case "friend_01":
				case "friend_02":
				case "friend_03":
				case "friend_list":
				case "friend_group":
					idx = 4;
					break;
				case "booking_list":
					idx = 2;
					break;
				case "my_know":
					idx = 3;
					break;
				case "my_club":
					idx = 5;
					break;
				case "my_modify":
					idx = 6;
					break;
			}
			
			if(idx != null){var imgName = $layer.find("nav li:eq(" + idx + ") img").attr("src").replace(".png", "_on.png");
				$layer.find("nav li:eq(" + idx + ")").addClass("gnb_on").find("img").attr("src", imgName);
			}
			
			$layer.find("p.my_photo:first img").attr("src", this.memberInfo["이미지"]);
			$layer.find("dl.my_profile>dt:first").html(this.memberInfo["닉네임"]);
			$layer.find("dl.my_profile p.graph_bar").width((this.memberInfo["점수"] * 2) + "px");
			$layer.find("dl.my_profile p.graph_txt>span:first").html(this.memberInfo["점수"]);
			$layer.find("dl.my_profile li.sex_m").html(this.memberInfo["성별"]);
			$layer.find("dl.my_profile li:eq(1)>span").html(this.memberInfo["핸디"]);
			$layer.find("dl.my_profile li:eq(2)>span").html(this.memberInfo["비거리"]);
		}
	}
	
	
	
	// footer
	function clsFooter()
	{
		this.bLoaded = false;
		this._loadpage = "../inc/footer.html";
		this._load();
	}
	
	
	clsFooter.prototype = {
		_load : function(){
			if($("footer").children().length > 0){
				$("footer").prepend("<div></div>").children(":first").load(this._loadpage);	
			}else{
				$("footer").load(this._loadpage);
			}
		}
	}
	
	function clsProfileLayer(direction){
		this._HTMLDom = null;
		this.data = null;
		this.direction = direction;
		this.objPos = null;
		this._loadpage = "../inc/layer.html div.profile_layer";
		
		this._init();
	}
	
	clsProfileLayer.prototype = {
		_init: function(){
			var thisClass = this;
			this.data = {
				"아이디": null
				, "이미지": null
				, "닉네임": null
				, "성별": null
				, "핸디": null
				, "비거리": null
			}
			
			this.objPos = {
				"left": 0
				, "top": 0
			}
			
			if(!this.direction) this.direction = "right";
			
			$("body").append("<div id='idProfileLayer'></div>").find("#idProfileLayer").hide().load(this._loadpage, function(){
				thisClass._HTMLDom = {
					"$layer": $("#idProfileLayer")
				}
				
				thisClass._HTMLDom["$layer"].mouseenter(function(){
					thisClass._HTMLDom["$layer"].show();
				}).mouseleave(function(){
					thisClass._HTMLDom["$layer"].hide();
				});
			});
		}
		, show: function($obj){
			var $layer = this._HTMLDom["$layer"];
			var pos = $obj.offset();
			var szClass = "";
			
			$layer.find("div:first").removeClass("profile_layer profile_layer02");
			switch(this.direction){
				case "left":
					szClass = "profile_layer02";
					break;
				case "right":
					szClass = "profile_layer";
					break;
			}
			
			$layer.find("div:first").addClass(szClass);
			
			$layer.find("p.profile_phto>img").attr("src", this.data["이미지"]);
			$layer.find("div.profile_cont>p.nickname_l").html(this.data["닉네임"]).next().html(this.data["성별"]);
			$layer.find("div.profile_cont>p.etc:eq(0)>span").html(this.data["핸디"]);
			$layer.find("div.profile_cont>p.etc:eq(1)>span").html(this.data["비거리"]);
			
			$layer.css({"position": "absolute", "left": (pos.left+this.objPos["left"])+"px", "top": (pos.top+this.objPos["top"])+"px"});
			$layer.show();
		}
		, hide: function(){
			this._HTMLDom["$layer"].hide();
		}
		, setData: function(obj){
			this.data = obj;
		}
		, setDirection: function(val){
			this.direction = val;
		}
		, setLeft: function(val){
			this.objPos["left"] = val;
		}
		, setTop: function(val){
			this.objPos["top"] = val;
		}
		, open: function($obj, thisData, direction, left, top){
			if(direction) this.setDirection(direction);
			if(left == 0 || left) this.setLeft(left);
			if(top == 0 || top) this.setTop(top);
			this.setData(thisData);
			this.show($obj);
		}
	}
		
	function clsMemberLayer(direction){
		this._HTMLDom = null;
		this.data = null;
		this.direction = direction;
		this.objPos = null;

		this._loadpage = "../inc/layer.html div.offer_layer";
		
		this._init();
	}
	
	clsMemberLayer.prototype = {
		_init: function(){
			var thisClass = this;
			this.data = [
				{
//							"아이디": null
//							, "이미지": null
//							, "닉네임": null
				}
			];
			
			if(!this.direction) this.direction = "right";
			this.objPos = {
				"left": 0
				, "top": 0
			}
			
			$("body").append("<div id='idMemberLayer'></div>").find("#idMemberLayer").hide().load(this._loadpage, function(){
				thisClass._HTMLDom = {
					"$layer": $("#idMemberLayer")
					, "$element": $("#idMemberLayer ul.offer_layer_cont li:first").clone(true)
				}
				
				thisClass._HTMLDom["$layer"].mouseenter(function(){
					thisClass._HTMLDom["$layer"].show();
				}).mouseleave(function(){
					thisClass._HTMLDom["$layer"].hide();
				});
			});
		}
		, show: function($obj){
			var $layer = this._HTMLDom["$layer"];
			var pos = $obj.offset();
			var szClass = "";
			
			switch(this.direction){
				case "left":
					szClass = "offer_layer";
					break;
				case "right":
					szClass = "offer_layer02";
					break;
			}
			$layer.find("div:first").removeClass("offer_layer offer_layer02").addClass(szClass);
			
			$layer.find("ul.offer_layer_cont").empty();
			for(var i=0;i<this.data.length;i++){
				$layer.find("ul.offer_layer_cont").append(this._HTMLDom["$element"].clone(true));
				
				$layer.find("ul.offer_layer_cont").find("li:last img").attr("src", this.data[i]["이미지"]);
				$layer.find("ul.offer_layer_cont").find("li:last p.dd_name").html(this.data[i]["닉네임"]);
			}
			
			$layer.css({"position": "absolute", "left": (pos.left+this.objPos["left"])+"px", "top": (pos.top+this.objPos["top"])+"px"});
			$layer.show();
		}
		, hide: function(){
			this._HTMLDom["$layer"].hide();
		}
		, setData: function(obj){
			this.data = obj;
		}
		, setDirection: function(val){
			this.direction = val;
		}
		, setLeft: function(val){
			this.objPos["left"] = val;
		}
		, setTop: function(val){
			this.objPos["top"] = val;
		}
		, open: function($obj, thisData, direction, left, top){
			if(direction) this.setDirection(direction);
			if(left == 0 || left) this.setLeft(left);
			if(top == 0 || top) this.setTop(top);
			this.setData(thisData);
			this.show($obj);
		}
	}
	
	function clsJoinroomLayer(){
		this._HTMLDom = null;
		this.data = null;
		this.objPos = null;
		this.btn = null;

		this._loadpage = "../inc/layer.html div.help_box";
		
		this._init();
	}
	
	clsJoinroomLayer.prototype = {
		_init: function(){
			var thisClass = this;
			this.data = [
				{
//							"아이디": null
//							, "이미지": null
//							, "닉네임": null
				}
			];
			
			this.objPos = {
				"left": 0
				, "top": 0
			}
			
			$("body").append("<div id='idJoinroomLayer'></div>").find("#idJoinroomLayer").hide().load(this._loadpage, function(){
				thisClass._HTMLDom = {
					"$layer": $("#idJoinroomLayer")
					, "$element": $("#idJoinroomLayer ul li:first").clone(true)
				}
				
				thisClass._HTMLDom["$layer"].mouseenter(function(){
					thisClass._HTMLDom["$layer"].show();
				}).mouseleave(function(){
					thisClass._HTMLDom["$layer"].hide();
				});
			});
		}
		, show: function($obj){
			var $layer = this._HTMLDom["$layer"];
			var pos = $obj.offset();
			var thisClass = this;
			
			$layer.find("ul").empty();
			for(var i=0;i<this.data.length;i++){
				$layer.find("ul").append(this._HTMLDom["$element"].clone(true));
			}
			$layer.find("ul li").each(function(n){
				$(this).find("img:first").attr("src", thisClass.data[n]["이미지"]);
				$(this).find("span").html(thisClass.data[n]["닉네임"]);
			});
			
			$layer.css({"position": "absolute", "left": (pos.left+this.objPos["left"])+"px", "top": (pos.top+this.objPos["top"])+"px"});
			$layer.find("a:has(img)").hide();
			if(this.btn) $layer.find("a:has(img[alt='" + this.btn + "'])").show();
			$layer.show();
		}
		, hide: function(){
			this._HTMLDom["$layer"].hide();
		}
		, setData: function(obj){
			this.data = obj;
		}
		, setBtn: function(val){
			this.btn = val;
		}
		, setLeft: function(val){
			this.objPos["left"] = val;
		}
		, setTop: function(val){
			this.objPos["top"] = val;
		}
		, open: function($obj, thisData, btn, left, top){
			if(btn) this.setBtn(btn);
			if(left == 0 || left) this.setLeft(left);
			if(top == 0 || top) this.setTop(top);
			this.setData(thisData);
			this.show($obj);
		}
	}
	
	function clsModalLoading(){
			this.idName = "idModalLoading";
			this.$text = null;
			
			this._init();
	}
	
	clsModalLoading.prototype = {
		_init: function(){
			//$("body").append("<div id='" + this.idName + "' style='position:relative; text-align:center;'><p style='position:absolute; top:40%; left:50%;'></p></div>");
			$("body").append("<div id='" + this.idName + "' style='display:none; overflow:hidden; width:100px; height:100px;'><div style='position:relative; width:100%; height:100%; left:50%; top:50%'></div><div style='position:relative; width:100%; height:0%'></div></div>");
			
			/*$("#" + this.idName).dialog({
				disabled: true
				, autoOpen: false
				, closeOnEscape: false
				, draggable: false
				, height: 100
				, width: 100
				, modal: true
				, resizable: false
				, create: function (event, ui){
					$(".ui-dialog-titlebar").css("display", "none");
				}
			});*/
		}
		, setText: function(val){
			if(val){
				$("#" + this.idName).find("div:eq(0)").css({
					height: "80%"
					, top: "40%"
				});

				$("#" + this.idName).find("div:eq(1)").height("20%").html(val);
			}else{
				$("#" + this.idName).find("div:eq(0)").css({
					height: "100%"
					, top: "50%"
				});
			}
		}
		, open: function(szText){
			var thisClass = this;
			
			if(szText === false) this.setText(false);
			else if(szText) this.setText(szText);
				
			if($.blockUI){
				$("#" + this.idName).find("div:first").spin({shadow: true});
				//$("#" + this.idName).dialog("open");
				$.blockUI({
					message: $("#" + this.idName)
					, css: {
						width: "100px"
						, height: "100px"
						, left: "50%"
						, top: "50%"
					}
				});
			}else{
				setTimeout(function(){
					thisClass.open();
				}, 100);
			}
		}
		, close: function(){
			var thisClass = this;
			
			if($.unblockUI){
				$("#" + this.idName).find("div:first").spin(false);
				//$("#" + this.idName).dialog("close");
				$.unblockUI();
			}else{
				setTimeout(function(){
					thisClass.close();
				}, 100);
			}
		}
	}
	
	// 페이징
	function clsPaging($layer, countPerPage, pagePerBlock){
		this._HTMLDom = {
			"$layer": $layer
		}
		
		this.pageData = {
			"현재페이지": null
			, "페이지당수": countPerPage
			, "블럭당페이지": pagePerBlock
			, "전체수": null
		}
		
		this._loadpage = "../inc/layer.html ul.pagenum_area";
		
		this._init();
	}
	
	clsPaging.prototype = {
		_init: function(){
			var thisClass = this;
			var $layer = this._HTMLDom["$layer"];

			$layer.load(this._loadpage, function(){
				thisClass._HTMLDom["$element"] = $layer.find("li:not(.pagen_btn):first").clone(true);
				
				$layer.find("li:not(.pagen_btn)").remove();
				
				thisClass._bind();
			});
		}
		, _bind: function(){
			var $layer = this._HTMLDom["$layer"];
			var thisClass = this;
			
			// 화살표 버튼 클릭시
			$layer.find("li.pagen_btn a").click(function(event){
				event.preventDefault();
				
				var idx = $layer.find("li.pagen_btn a").index($(this));
				var curPage = thisClass.pageData["현재페이지"];
				var totalPage = Math.ceil(thisClass.pageData["전체수"]/thisClass.pageData["페이지당수"]);
				
				if((idx < 2 && curPage == 1) || (idx > 1 && curPage >= totalPage)) return;
				
				switch(idx){
					case 0:
						curPage = 1;
						break;
					case 1:
						curPage --;
						break;
					case 2:
						curPage++;
						break;
					case 3:
						curPage = totalPage;
						break;
				}
				thisClass.setPage(curPage);
				$(thisClass).trigger("evtPageClick");
			});
		}
		, setTotalCount: function(val){
			this.pageData["전체수"] = val;
		}
		, setPage: function(val){
			this.pageData["현재페이지"] = val;
			this.display();
		}
		, getPage: function(val){
			return this.pageData["현재페이지"];
		}
		, getCountPerPage: function(){
			return this.pageData["페이지당수"];
		}
		, display: function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var startPage = Math.ceil(this.pageData["현재페이지"]/this.pageData["페이지당수"]);
			var endPage = startPage+this.pageData["블럭당페이지"]-1;
			var totalPage = Math.ceil(this.pageData["전체수"]/this.pageData["페이지당수"]);
			var thisClass = this;
			
			if(endPage > totalPage) endPage = totalPage;
			
			$layer.find("li:not(.pagen_btn)").remove();
			
			for(var i=startPage;i<=endPage;i++){
				$layer.find("li.pagen_btn:eq(2)").before($element.clone(true)).prev("li").find("a").html(i);
			}
			
			$layer.find("li:not(.pagen_btn)").removeClass("point").eq(this.pageData["현재페이지"]-1).addClass("point"); // 현재 페이지에 클래스 설정
			// 페이지 버튼 클릭시
			$layer.find("li:not(.pagen_btn) a").click(function(event){
				event.preventDefault();
				
				var curPage = thisClass.pageData["현재페이지"];
				var thisPage = $layer.find("li:not(.pagen_btn) a").index($(this))+1;
				
				if(curPage == thisPage) return;
				
				thisClass.setPage(thisPage);
				
				$(thisClass).trigger("evtPageClick");
			});
		}
	}
	
	function clsGlobalComm()
	{
		this.loginData = null;
		this.loginRequest = null;
		
		this.memberData = null;
		this.bookingAlarmList = null;
		this.friendAlarmList = null;
		this.alarmList = null;
		
		this._init();
	}
	
	clsGlobalComm.prototype = {
		_init: function(){
			this.loginRequest = {
				"아이디": null
				, "비밀번호": null
			}
			
			this.loginData = {
				"결과코드": null
				, "아이디": null
			}
			
			this.memberData = {
				"이미지": null
				, "닉네임": null
				, "점수": null
				, "성별": null
				, "핸디": null
				, "비거리": null
			}
			
			this.bookingAlarmList = [
				{
					"종류": null // 부킹예약, 조인룸초대, 조인룸참여
					, "아이디": null // 조인룸초대, 조인룸참여
					, "닉네임": null // 조인룸초대, 조인룸참여
					, "키": null
					, "메시지": null
				}
			];
			
			this.friendAlarmList = [
				{
					"종류": null // 친구요청
					, "아이디": null // 친구요청
					, "닉네임": null // 친구요청
					, "이미지": "../images/board/default_35_35.gif"
					, "메시지": "바보퉁이 님의 친구요청"
				}
			];
			
			this.alarmList = [
				{
					"종류": null // 나의동호회게시글, 나의글나이스샷, 나의동호회가입, 나의글댓글
					, "키": null
					, "메시지": null
					, "아이디": null
					, "닉네임": null
					
				}
			];
		}
		, setLoginRequest: function(key, val){
			this.loginRequest[key] = val;
		}
		, getLoginInfo: function(){
			var thisClass = this;
			
			document.objGlobal.ajax({
				"sid":"US001",
				"servicename":"login",
				"listcount":10,
				"currpageno":1
			}, {
				"userId":  thisClass.loginRequest["아이디"]
				, "pw": thisClass.loginRequest["비밀번호"]
			}, function(ret){
				thisClass.loginData = {
					"결과코드": ret["msp"]["contents"]["serviceResult"]
					, "아이디": null
					, "메시지": document.objGlobal.getResultMsg("login", ret["msp"]["contents"]["serviceResult"])
				}
				
				if( ret["msp"]["contents"]["serviceResult"] == "00000"){
					thisClass.loginData["아이디"] = ret["msp"]["contents"]["items"][0]["userNo"];
				}
				
				$(thisClass).trigger("evtFinishLoginInfo");
			});
			
			// ajax
			/*var req = '{"msp":{"header":{"client":"","device":{"model":"UNIT-1"}},"params":{"pub":{"sid":"US001","servicename":"login","listcount":10,"currpageno":1},"parameter":[{"@name":"userId","$":"' + this.loginRequest["아이디"] + '"},{"@name":"pw","$":"' + this.loginRequest["비밀번호"] + '"}]}}}';
			$.ajax({
				//url: "http://darkflash.woobi.co.kr/ajax_proc.php"
				url: "http://192.168.0.81:8080/dcd/request.do"
				, type: "GET"
				, data: {
					"userid": ""
					, "method": "json"
					, "req": req
				}
				, dataType: "jsonp"
				, jsonp: "msp300"
				, success: function(ret, sta){
					var rnd = document.objGlobal.random(0, 1);
					
					this.loginData = {
						"결과코드": rnd
						, "아이디": thisClass.loginRequest["아이디"]
					}
					
					//if(ret["msp"]["contents"]["boolean"]) alert("성공");
					//else alert("실패");
					
					$(thisClass).trigger("evtFinishLoginInfo");
				}
				, error: function(xhr, sta, err){
					alert(sta)
				}
			});*/
		}
		, getLoginData: function(){
			return this.loginData;
		}
		, getMemberInfo: function(key){
			var thisClass = this;
			
			//ajax
			setTimeout(function(){
				thisClass.memberData = {
					"이미지": "../images/board/default_130_130.gif"
					, "닉네임": "잭니클라우스"
					, "점수": 50
					, "성별": "남자"
					, "핸디": "109"
					, "비거리": "150"
				}
				
				$(thisClass).trigger("evtFinishMemberInfo");
			}, 500);
		}
		, getMemberData: function(){
			return this.memberData;
		}
		, getBookingAlarmList: function(key){
			var thisClass = this;
			
			//ajax
			setTimeout(function(){
				thisClass.bookingAlarmList = [
					{
						"종류": "부킹예약"
						, "아이디": null // 조인룸초대, 조인룸참여
						, "닉네임": null // 조인룸초대, 조인룸참여
						, "키": "001"
						, "메시지": "2012.02.12 예정인 부킹을 예약하였습니다."
					}
					, {
						"종류": "조인룸초대"
						, "아이디": "sky72" // 조인룸초대, 조인룸참여
						, "닉네임": "골프알바" // 조인룸초대, 조인룸참여
						, "키": "001"
						, "메시지": "골프알바 님의 조인룸 초대"
					}
					, {
						"종류": "조인룸참여"
						, "아이디": "sky72" // 조인룸초대, 조인룸참여
						, "닉네임": "바보퉁이" // 조인룸초대, 조인룸참여
						, "키": "001"
						, "메시지": "바보퉁이 님이 회원님의 조인룸에 참여하였습니다."
					}
					, {
						"종류": "예정조인룸참여"
						, "아이디": "sky72" // 조인룸초대, 조인룸참여
						, "닉네임": "쿠하카" // 조인룸초대, 조인룸참여
						, "키": "001"
						, "메시지": "쿠하카 님이 2012.02.12 예정인  조인룸에 참여하였습니다."
					}
				];
				
				$(thisClass).trigger("evtFinishBookingAlarmList");
			}, 500);
		}
		, getBookingAlarmData: function(){
			return this.bookingAlarmList;
		}
		, getFriendAlarmList: function(key){
			var thisClass = this;
			
			//ajax
			setTimeout(function(){
				thisClass.friendAlarmList = [
					{
						"종류": "친구요청" // 친구요청
						, "아이디": "sky72" // 친구요청
						, "닉네임": "바보퉁이1" // 친구요청
						, "이미지": "../images/board/default_35_35.gif"
						, "메시지": "바보퉁이1 님의 친구요청"
					}
					, {
						"종류": "친구요청" // 친구요청
						, "아이디": "sky73" // 친구요청
						, "닉네임": "바보퉁이2" // 친구요청
						, "이미지": "../images/board/default_35_35.gif"
						, "메시지": "바보퉁이2 님의 친구요청"
					}
					, {
						"종류": "친구요청" // 친구요청
						, "아이디": "sky74" // 친구요청
						, "닉네임": "바보퉁이3" // 친구요청
						, "이미지": "../images/board/default_35_35.gif"
						, "메시지": "바보퉁이3 님의 친구요청"
					}
				];
				
				$(thisClass).trigger("evtFinishFriendAlarmList");
			}, 500);
		}
		, getFriendAlarmData: function(){
			return this.friendAlarmList;
		}
		, getAlarmList: function(key){
			var thisClass = this;
			
			//ajax
			setTimeout(function(){
				thisClass.alarmList = [
					{
						"종류": "나의동호회게시글" // 나의동호회게시글, 나의글나이스샷, 나의동호회가입, 나의글댓글
						, "키": "001"
						, "메시지": "바보퉁이 님이 대학생 골프연합회의 필드에 게시글을 남겼습니다."
						, "아이디": "sky72"
						, "닉네임": "바보퉁이"
						
					}
					, {
						"종류": "나의글나이스샷" // 나의동호회게시글, 나의글나이스샷, 나의동호회가입, 나의글댓글
						, "키": "001"
						, "메시지": "쿠하카 님이 회원님의 글에 나이스샷을 외쳤습니다."
						, "아이디": "sky73"
						, "닉네임": "쿠하카"
						
					}
					, {
						"종류": "나의동호회가입" // 나의동호회게시글, 나의글나이스샷, 나의동호회가입, 나의글댓글
						, "키": "001"
						, "메시지": "바보퉁이 님이 우리동네 골프클럽 동호회에 가입하였습니다."
						, "아이디": "sky72"
						, "닉네임": "바보퉁이"
						
					}
					, {
						"종류": "나의글댓글" // 나의동호회게시글, 나의글나이스샷, 나의동호회가입, 나의글댓글
						, "키": "001"
						, "메시지": "쿠하카 님이 회원님의 글에 댓글을 남겼습니다."
						, "아이디": "sky73"
						, "닉네임": "쿠하카"
						
					}
				];
				
				$(thisClass).trigger("evtFinishAlarmList");
			}, 500);
		}
		, getAlarmData: function(){
			return this.alarmList;
		}
	}
	
	
	
	// 전역 클래스
	function clsGlobal(){
		this.objTopMenu = null;
		this.objLeftMenu = null;
		this.objFooter = null;
		this.objMypageTop = null;
		
		this.objComm = null;
		this.objProfileLayer = null;
		this.objMemberLayer = null;
		this.objJoinroomLayer = null;
		this.objModalLoading = null;
		this.clsPaging = null;
		
		this.resultMsg = null;
		this._finishPreload = null;
		
		this._init();
	}
	
	clsGlobal.prototype = {
		_init: function(){
			// top메뉴 객체 생성
			if($("body header").is("header")) this.objTopMenu = new clsTopMenu();
			
			// 왼쪽 메뉴가 없는 페이지는 left메뉴 객체 생성하지 않음.
			if($("div.#container:first").children().is("#left_area")) this.objLeftMenu = new clsLeftMenu();
			
			// footer 객체 생성
			this.objFooter = new clsFooter();
			
			this.objComm = new clsGlobalComm();
			this.objMypageTop = new clsMypageTop();
			this.objProfileLayer = new clsProfileLayer();
			this.objMemberLayer = new clsMemberLayer();
			this.objJoinroomLayer = new clsJoinroomLayer();
			this.objModalLoading = new clsModalLoading();
			this.clsPaging = clsPaging;
			
			this._bind();
			
			// 페이지에 사용될 정보를 비동기식으로 로드
			this._preload();
			
			// 로그인시
			if(this.getCookie("member_id")){
				// 나의 정보
				this.objComm.getMemberInfo(this.getCookie("member_id"));
			}
		}
		, _preload: function(){
			var thisClass = this;
			
			// 로그인 정책
			$.ajax({
				url: "../inc/auth.policy"
				, type: "get"
				, dataType: "json"
				, async: false
				, success: function(ret, sta){
					var aFileName = document.location.href.match(/(?:.+)\/(.+)\/(.+)\.(html|htm)/);
					var szFileName = aFileName[2];
					
					if(!thisClass.getCookie("member_id")){
						if(ret[szFileName]) document.location.href = ret[szFileName];
					}
				}
			});
			
			
			$.ajax({
				url: "../js/jquery.blockUI.js"
				, type: "get"
				, dataType: "script"
				, async: false
			});
			
			// 서버 메시지맵
			$.ajax({
				url: "../inc/result.message"
				, type: "get"
				, dataType: "json"
				, async: false
				, success: function(ret, sta){
					thisClass.resultMsg = ret;
				}
				, error: function(){
					alert("서버 메시지맵 로딩 오류 발생");
				}
			});
		}
		, _bind: function(){
			var thisClass = this;
			
			// 로그인 완료후
			$(this.objComm).bind("evtFinishLoginInfo", function(){
				var thisData = this.getLoginData();
				
				thisClass.objLeftMenu.loginSpinEnd();
				
				if(thisData["메시지"]){
					alert(thisData["메시지"]);
					return;
				}
				
				document.objGlobal.setCookie("member_id", thisData["아이디"], null, "/");
				document.location.reload();
			// 회원정보 완료후
			}).bind("evtFinishMemberInfo", function(){
				var thisData = this.getMemberData();
				
				thisClass.objMypageTop.setMemberInfo(thisData);
			// 부킹알람 완료후
			}).bind("evtFinishBookingAlarmList", function(){
				var thisData = this.getBookingAlarmData();
				
				thisClass.objTopMenu.setBookingAlarmList(thisData);
			// 친구알람 완료후
			}).bind("evtFinishFriendAlarmList", function(){
				var thisData = this.getFriendAlarmData();
				
				thisClass.objTopMenu.setFriendAlarmList(thisData);
			// 알람 완료후
			}).bind("evtFinishAlarmList", function(){
				var thisData = this.getAlarmData();
				
				thisClass.objTopMenu.setAlarmList(thisData);
			});
			
			// 왼쪽메뉴 로딩완료후
			$(this.objLeftMenu).bind("onload", function(event){
				thisClass._leftMenuBind();
			});
			
			// 탑메뉴 로딩완료후
			$(this.objTopMenu).bind("onload", function(event){
				// 로그인시
				if(thisClass.getCookie("member_id")){
					// 부킹알람
					thisClass.objComm.getBookingAlarmList(thisClass.getCookie("member_id"));
					// 친구알람
					thisClass.objComm.getFriendAlarmList(thisClass.getCookie("member_id"));
					// 알람
					thisClass.objComm.getAlarmList(thisClass.getCookie("member_id"));
				}
				
				thisClass._topMenuBind();
			});
		}
		, _leftMenuBind: function(){
			var thisClass = this;
			
			// 로그인클릭
			(this.objLeftMenu.$getBtnLogin()).click(function(event){
				event.preventDefault();
				thisClass.login();
			});
			
			// 비밀번호 엔터시 로그인
			(this.objLeftMenu.$getInputPasswd()).keydown(function(event){
				if(event.keyCode == 13) thisClass.login();
			});
			
			// 대메뉴 마우스오버
			(this.objLeftMenu.$getsMenuStep1()).mouseenter(function(event){
				var actionTimer = thisClass.objLeftMenu.getActionTimer();
				if(actionTimer) thisClass.objLeftMenu.setActionTimer(clearTimeout(actionTimer));
				
				// 대메뉴 전체 볼드 off
				(thisClass.objLeftMenu.$getsMenuStep1()).find("img").each(function(){
					$(this).attr("src", $(this).data("src") + ".gif");
				})
				
				// 선택대메뉴 볼드 on
				$(this).find("img").attr("src", $(this).find("img").data("src") + "_on.gif");
				
				
				var $layer = $(this).next();
				
				// 전체 하위메뉴 숨김
				(thisClass.objLeftMenu.$getsMenuStep2()).not($layer).stop().hide("fast");
				
				// 현재 하위메뉴 보임
				$layer.show("slow");
			}).mouseleave(function(){
				var iTimer = setTimeout(function(){
					thisClass.objLeftMenu.setDefault();
				}, 500);
				
				thisClass.objLeftMenu.setActionTimer(iTimer);
			});
			
			// 하위메뉴 마우스오버
			(this.objLeftMenu.$getsMenuStep2()).find("li").mouseenter(function(){
				var actionTimer = thisClass.objLeftMenu.getActionTimer();
				if(actionTimer) thisClass.objLeftMenu.setActionTimer(clearTimeout(actionTimer));
				
				// 전체 하위메뉴 이미지 off
				(thisClass.objLeftMenu.$getsMenuStep2()).find("img").each(function(){
					$(this).attr("src", $(this).data("src") + ".gif");
				});
				
				// 현재 하위메뉴 이미지 on
				$(this).find("img").attr("src", $(this).find("img").data("src") + "_on.gif");
			}).mouseleave(function(){
				var iTimer = setTimeout(function(){
					thisClass.objLeftMenu.setDefault();
				}, 500);
				
				thisClass.objLeftMenu.setActionTimer(iTimer);
			});
			
			
			// 아이디 비밀번호 찾기
			this.objLeftMenu.$getBtnFindIdPw().click(function(event){
				event.preventDefault();
				var href = $(this).attr("href");
				
				window.open(href);
			});
			
			
			// 디폴트 메뉴 설정
			this.objLeftMenu.setActionTimer(setTimeout(function(){
				thisClass.objLeftMenu.setDefault();
			}, 1));
		}
		, _topMenuBind: function(){
			var thisClass = this;
			
			// 로그아웃
			(this.objTopMenu.$getBtnLogout()).click(function(event){
				event.preventDefault();

				thisClass.logout();
			});
		}
		, logout: function(){
			var thisClass = this;
			
			this.ajax({
				"sid":"US001",
				"servicename":"logout",
				"listcount":10,
				"currpageno":1
			}, {
				"userId": this.getCookie("member_id")
			}, function(ret){
				document.objGlobal.delCookie("member_id", "/");
				document.location.reload();
			});
		}
		, login: function(){
			var id = (this.objLeftMenu.$getInputID()).val();
			var passwd = (this.objLeftMenu.$getInputPasswd()).val();
			
			if(id == ""){
				alert("아이디를 입력해 주십시요.");
				(objLeftMenu.$getInputID()).trigger("focus");
				return;
			}else if(passwd == ""){
				alert("비밀번호를 입력해 주십시요.");
				(objLeftMenu.$getInputPasswd()).trigger("focus");
				return;
			}
			
			this.objComm.setLoginRequest("아이디", id);
			this.objComm.setLoginRequest("비밀번호", passwd);
			this.objLeftMenu.loginSpinStart();
			this.objComm.getLoginInfo();
		}
		// 페이지 전달 인자 파싱
		, getParam: function(key){
			var ret = (this.getObjParam())[key];
			if(!ret) ret = "";
			
			return ret;
		}
		, getObjParam: function(){
			var _parammap = {};
		    document.location.search.replace(/\??(?:([^=]+)=([^&]*)&?)/g, function () {
		        function decode(s) {
		            return decodeURIComponent(s.split("+").join(" "));
		        }
		
		        _parammap[decode(arguments[1])] = decode(arguments[2]);
		    });
		    
		    return _parammap;
		}
		// ie를 위해
		, setPlaceHolder: function(){
			if (!("placeholder" in document.createElement("input"))) {
				$(":input[placeholder]").each(function () {
					var $this = $(this);
					var pos = $this.offset();
					
					if (!this.id) this.id = "jQueryVirtual_" + this.name;
					
					if (this.id) {
						$this.after("<label id='jQueryVirtual_label_" + this.id + "'>" + $this.attr("placeholder") + "</label>");
						$("#jQueryVirtual_label_" + this.id).css({"position":"absolute", "color":"#999", "display":"none", "cursor":"text", "left":10, "margin-top":4, "width":$this.width()});
					}
				}).focus(function () {
					var $this = $(this);
					$("#jQueryVirtual_label_" + $this.attr("id")).hide();
				}).blur(function () {
					var $this = $(this);
			
					if(!$.trim($this.val()))
						$("#jQueryVirtual_label_" + $this.attr("id")).show();
					else $("#jQueryVirtual_label_" + $this.attr("id")).hide();
				}).trigger("blur");
				
				$("label[id^=jQueryVirtual_label_]").each(function(){
					$(this).click(function(){
						var targetID = this.id.replace("jQueryVirtual_label_", "");
						
						$("#" + targetID).trigger("focus");
					});
				});
			}
		}
		, getCookie: function(name){
			var cname = name + "=";
			var dc = document.cookie;
			if (dc.length > 0) {
				begin = dc.indexOf(cname);
				if (begin != -1) {
					begin += cname.length;
					end = dc.indexOf(";", begin);
					if (end == -1) end = dc.length;
					return unescape(dc.substring(begin, end));
				}
			}
			return null;
		}
		, setCookie: function(name, value, expiredays, path, domain, secure){
			var toDate = new Date();
			toDate.setHours(23);
			toDate.setMinutes(59);
			toDate.setSeconds(59);
			toDate.setDate(toDate.getDate() + expiredays);
			document.cookie = name + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + toDate.toGMTString()) + ((path == null) ? "" : "; path=" + path) + ((domain == null) ? "" : "; domain=" + domain) + ((secure == null) ? "" : "; secure");
		}
		, delCookie: function(name, path, domain){
			if (this.getCookie(name)) {
				document.cookie = name + "=" + ((path == null) ? "" : "; path=" + path) + ((domain == null) ? "" : "; domain=" + domain) + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
			}
		}
		, getByteLen: function(str){
			var ibyte = 0;

		    for (var i = 0; i < str.length; i++) {
		        var tmp = escape(str.charAt(i));
		        if (tmp.length == 1) ibyte++;
		        else if (tmp.indexOf("%u") != -1) ibyte += 2;
		        else if (tmp.indexOf("%") != -1) ibyte += tmp.length/3;
		    }
		
		    return ibyte;
		}
		, setWindowSize: function(){
			if($.browser.webkit && $.browser.safari){
				var wrapWidth = $(window).width(); 
			    var wrapHeight = $("body").height(); 
			    
			    window.resizeTo(wrapWidth, wrapHeight); 
			    
			    setTimeout(function(){
			    	var w1 = $(window).width(); 
				    var h1 = $(window).height(); 
				    
				    // 크롬의 문제로 W, H 값을 따로 설정 
				    // window.resizeBy(wrapWidth - w1, wrapHeight-h1); 
				    window.resizeBy(wrapWidth - w1, 0); 
				    window.resizeBy(0, wrapHeight-h1+10); 
			    }, 300);
			}else{
				var wrapWidth = $(window).width(); 
			    var wrapHeight = $("body").height(); 
			
			    window.resizeTo(wrapWidth, wrapHeight); 
			
			    var w1 = $(window).width(); 
			    var h1 = $(window).height(); 
			
			    // 크롬의 문제로 W, H 값을 따로 설정 
			    // window.resizeBy(wrapWidth - w1, wrapHeight-h1); 
			    window.resizeBy(wrapWidth - w1, 0); 
			    window.resizeBy(0, wrapHeight-h1+10); 
			}
		}
		, random: function(iMin, iMax){
			return Math.round(Math.random() * (iMax - iMin)) + iMin;
		}
		, number_format: function(val){
			val += "";
			var Re = /[^0-9]/g;
			var ReN = /(-?[0-9]+)([0-9]{3})/;
			val = val.replace(Re,'');              
			while (ReN.test(val)) { 
				val = val.replace(ReN, "$1,$2"); 
			}
			return val;
		}
		, getCKOption: function(){
			return {
				toolbar: [
					{ name: 'document', items : [ 'Source','-','NewPage','DocProps','Preview','Print','-','Templates' ] },
					{ name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
					{ name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
					{ name: 'colors', items : [ 'TextColor','BGColor' ] },
					{ name: 'tools', items : [ 'Maximize', 'ShowBlocks' ] },
					{ name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] },
					{ name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'HiddenField' ] },
					{ name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
					{ name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv',
					'-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
					{ name: 'links', items : [ 'Link','Unlink','Anchor' ] },
					{ name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] }
				]
			};
		}
		// 오브젝트 복사
		, objectCopy: function(src){
			var constructor = null;
			var dst = null;
			
			if(src.constructor){
				var match = src.constructor.toString().match(/function ([^\(]*)/);
			
				constructor = (match && match[1]) || null;
			}
			
			if(typeof src == "object" && constructor){
				dst = eval("new " + constructor + "()");
				if(src.prototype){
					for(var key in src.prototype){
						dst.prototype[key] = this.objectCopy(src.prototype[key]);
					}
				}
				
				for(var key in src){
					dst[key] = this.objectCopy(src[key]);
				}
				
				return dst;
			}
			
			dst = src;
			
			return dst;
		}
		, getResultMsg: function(serviceName, resultCode, aVar){
			if(!this.resultMsg) return null;
			if(!this.resultMsg[serviceName]) return null;
			if(!this.resultMsg[serviceName][resultCode]) return null;
			
			var szRet = this.resultMsg[serviceName][resultCode];
			
			if(aVar){
				for(var i=0;i<aVar.length;i++){
					while(szRet.indexOf("{" + i + "}") != -1){
						szRet = szRet.replace("{" + i + "}", aVar[i]);
					}
				}
			}
			return szRet;
		}
		, getRequestString: function(objPub, objParameter){
			var szPub = "";
			var szParameter = "";
			var szRet = '{"msp":{"header":{"client":"","device":{"model":"UNIT-1","firmware":"ios292sd","ip":"192.168.0.1"}},';
			
			szRet += '"params":{"pub":{';
			
			if(typeof objPub == "string"){
				szPub = objPub;
			}else{
				for(var key in objPub){
					if(szPub) szPub += ",";
					szPub += '"' + key + '":"' + objPub[key] + '"';
				}
			}
			
			szRet += szPub + "},";
			szRet += '"parameter":[';
			
			if(typeof objParameter == "string"){
				szParameter += objParameter;
			}else{
				for(var key in objParameter){
					if(szParameter) szParameter += ",";
					szParameter += '{"@name":"' + key + '","$":"' + objParameter[key] + '"}';
				}
			}
			
			szRet += szParameter + "]}}}";
			
			return szRet;
		}
		, ajax: function(objPub, objParameter, callback, bDebug){
			var thisClass = this;
			
			if(bDebug){
				this.objModalLoading.close();
				
				if($("textarea#idDebug").length == 0){
					$("body").prepend("<textarea id='idDebug' />");
				}
				$("textarea#idDebug").val(this.getRequestString(objPub, objParameter));
			}
			
			$.ajax({
				url: "http://192.168.0.81:8080/dcd/request.do"
				, type: "GET"
				, data: {
					"userid": this.getCookie("member_id")
					, "method": "json"
					, "req": this.getRequestString(objPub, objParameter)
				}
				, dataType: "jsonp"
				, jsonp: "msp300"
				, timeout: 10000
				, success: function(ret, sta){
					if(ret["msp"]["result"]["code"] != "00000"){
						alert("시스템 오류입니다. 관리자에게 문의 바랍니다.\n오류코드 E5530012\n담당자 : 천재민 매니저 1577-1577");
						return;
					}
					
					callback(ret);
				}
				, error: function(xhr, sta, err){
					alert("시스템 오류입니다. 관리자에게 문의 바랍니다.\n오류코드 E454900\n담당자 : 천재민 매니저 1577-1577");
					return;
				}
				, complete: function(xhr, sta){
					
				}	
				, beforeSend: function(){
					
				}
			});
		}
	}
	
	document.objGlobal = new clsGlobal();
	
	if($.datepicker){
		// 달력 default 설정
		$.datepicker.setDefaults({
			monthNamesShort: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월']
			, monthNames: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월']
			, dayNamesMin: ['일','월','화','수','목','금','토']
			, appendText: "yyyy-mm-dd"
			, constrainInput: true
			, weekHeader: "Wk"
			, dateFormat: "yy-mm-dd"
			, autoSize: true
			, changeMonth: true
			, changeYear: true
			, showMonthAfterYear: true
		});
	}
	
	// 타이틀 설정
	$(document).attr("title", "::: 골프인 :::");
});